package GUI;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import Gamefield.Field;
import Gamefield.Gamefield;
import Gamefield.Tray;
import Pieces.Piece;
import Pieces.PiecePlayerEnum;

public class ConsolenGUI {

	public String GetNextMove() {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String curline ="";
		try {
			curline = in.readLine();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return curline;
	}

	public void printBoard(Gamefield gamefield){
		Field[][] field = gamefield.getField();
		Tray t1 = gamefield.getTray(PiecePlayerEnum.White);
		Tray t2 = gamefield.getTray(PiecePlayerEnum.Black);
		StringBuilder sb = new StringBuilder();

		sb.append("  A B C \n");
		for (int row = 1; row < field.length; row++) {
			sb.append(row + " ");
			for (int col = 1; col < field[row].length; col++) {
				sb.append(field[row][col].toString() + " ");
			}
			sb.append("\n");
		}	
		
		sb.append("Tray " + PiecePlayerEnum.White + ": ");
		
		for (Piece p : t1.getCapturedPieces()) {
			sb.append(p.toString() + "|");
		}
		
		sb.append("\nTray " + PiecePlayerEnum.Black + ": ");
		
		for (Piece p : t2.getCapturedPieces()) {
			sb.append(p.toString() + "|");
		}
		
		sb.append("\n");
		System.out.println(sb.toString());
	}
}
